url = 'https://www.acwing.com/problem/content/910/'

# 由于区间选点已经证明了区间的不相交性

n = int(input())

data = [list(map(int,input().split())) for i in range(n)]

res = 0
last = -1e10

data.sort(key=lambda x:x[-1])

for i in range(n):
    if data[i][0] > last:
        res+=1
        last = data[i][-1]
        

print(res)